<?php

use Illuminate\Database\Seeder;
use App\Models\Category;

use Faker\Factory as Faker;

class CategoryTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
    	Category::truncate();
    	$res = factory(\App\Models\Category::class, 5)->create();
    	$res->each(function($item) {
    		$num = random_int(3, 8);
    		$item->subcates()->saveMany(factory(\App\Models\Category::class, $num)->make());
    	});
    }
}
